'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    const {
      INTEGER,
      STRING,
      DATE,
    } = Sequelize;
    return await queryInterface.createTable('receivingaddress', {
      id: {
        type: INTEGER,
        allowNull: false,
        primaryKey: true,
        autoIncrement: true,
        comment: '序号',
      },
      consignee: {
        type: STRING(30),
        allowNull: false,
        comment: '收货人',
      },
      province: {
        type: STRING(50),
        allowNull: false,
        comment: '省',
      },
      city: {
        type: STRING(50),
        allowNull: false,
        comment: '市',
      },
      county: {
        type: STRING(50),
        allowNull: false,
        comment: '县',
      },
      street: {
        type: STRING(50),
        allowNull: false,
        comment: '街道/镇',
      },
      detailed: {
        type: STRING(200),
        allowNull: false,
        comment: '详细地址',
      },
      tel: {
        type: STRING(20),
        allowNull: false,
        comment: '手机号码',
      },
      email: {
        type: STRING(50),
        comment: '邮箱',
      },
      address_alias: {
        type: STRING(50),
        comment: '地址别名',
      },
      default_address: {
        type: INTEGER(2),
        allowNull: false,
        comment: '是否是默认地址，1 表示是，反之',
      },
      uid: {
        type: INTEGER,
        allowNull: false,
        comment: '用户ID对应关系',
      },
      createdDate: {
        type: DATE,
        allowNull: false,
        comment: '创建时间',
      },
      updatedDate: {
        type: DATE,
        allowNull: false,
        comment: '更改时间',
      },
    });
  },

  down: async queryInterface => {
    return await queryInterface.dropTable('receivingaddress');
  },
};
